﻿using System;
using MugenInjection.Infrastructure;
using MugenInjection.Interface;

namespace MugenInjection.Attributes
{
    /// <summary>
    /// Represents the base class for resolve attributes.
    /// </summary>
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter,
        AllowMultiple = false, Inherited = true)]
    public abstract class ResolverAttribute : Attribute
    {
        #region Constructor

        /// <summary>
        /// Initializes a new instance of the <see cref="ResolverAttribute"/> class.
        /// </summary>
        protected ResolverAttribute()
        {
        }

        #endregion

        #region Abstract or virtual methods

        /// <summary>
        /// Determines whether the specified request can be resolved.
        /// </summary>
        /// <param name="bindingContext">The specified <see cref="IBindingContext"/>.</param>
        /// <returns><c>True</c> if the specified service has been resolved; otherwise, <c>false</c>.</returns>
        public abstract bool CanResolve(IBindingContext bindingContext);

        /// <summary>
        /// Resolves instance for the specified <see cref="IBindingContext"/>.
        /// </summary>
        /// <param name="bindingContext">The specified <see cref="IBindingContext"/>.</param>
        /// <returns>An instance of the service.</returns>
        public abstract object Resolve(IBindingContext bindingContext);

        #endregion
    }
}